import scrapy
from mql_demo.items import MqlDemoItem
#Scrapy的爬虫绝对不能通过python直接运行这个文件来运行。

class MqlSpider(scrapy.Spider):
    name = 'mql'#爬虫程序的名称
    allowed_domains = ['bbs.bccn.net']#定义允许爬取的域名列表
    start_urls = ['http://bbs.bccn.net/']#开始爬取的网址列表

    def parse(self, response):#parse----实际爬取数据的python代码
        item=MqlDemoItem()
        title=response.css("td.title>a::text").extract()
        authors=response.xpath("//span[@class='1_last_t']/a/text()").extract()
        replytimes=response.xpath("//td[@class='1_au']/a/text()").extract()
        for title,replytime,author in zip(title,replytimes,authors):
            item['title']=title
            item['replytime']=replytime
            item['author']=author
            yield item
